﻿<Fluent:RibbonWindow xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:DaxStudio" x:Class="DaxStudio.DaxStudioWindow"
        Title="DaxStudioWindow" 
        x:Name="Window"
        mc:Ignorable="d" xmlns:my="clr-namespace:DaxStudio"
                     xmlns:ViewModel="clr-namespace:DaxStudio.ViewModel"
                     xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent" Loaded="DaxStudioWindowLoaded" Height="1025" Width="1079">
    
    <Grid x:Name="LayoutRoot">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>
<!--
        <ribbon:Ribbon x:Name="Ribbon" >
            
            <ribbon:RibbonTab x:Name="HomeTab" 
				Header="Home">
				<ribbon:RibbonGroup x:Name="Group1" 
					Header="Query" Width="64.093">
					<ribbon:RibbonSplitButton Margin="0,0,-20,-19" Label="Run">
						<ribbon:RibbonSplitButton.ControlSizeDefinition>
							<ribbon:RibbonControlSizeDefinition/>
						</ribbon:RibbonSplitButton.ControlSizeDefinition>
                        <MenuItem Header="Run (Query Table)" />
                        <MenuItem Header="Run (Statict Results)" />
                        <MenuItem Header="Run (Validate)" />
                    </ribbon:RibbonSplitButton>
				</ribbon:RibbonGroup>
				<ribbon:RibbonGroup x:Name="Connection" Header="Connection" Margin="0" Width="172">
					<ribbon:RibbonComboBox Margin="0,0,43,-1" RenderTransformOrigin="0.823,0.409" Name="cboDatabase" />
                    <ribbon:RibbonButton Content="Button" Height="23" HorizontalAlignment="Left" Margin="0,0,0,0" Name="ribbonButton1" VerticalAlignment="Top" Width="75" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup Header="Output" Margin="0">
                    <ribbon:RibbonComboBox Margin="0,0,0,0" RenderTransformOrigin="0.823,0.409" Name="cboOutputTo" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup Header="Options" Margin="0"/>
                <ribbon:RibbonGroup Header="Help" Margin="0">
                    <ribbon:RibbonButton Content="Documentation" Height="20" HorizontalAlignment="Left" Margin="0,0,0,0" Name="btnDoco" VerticalAlignment="Top" Width="110" Label="Documentation" ToolTip="Documentation Codeplex Wiki">
                        <ribbon:RibbonButton.ControlSizeDefinition>
                            <ribbon:RibbonControlSizeDefinition IsLabelVisible="True" ImageSize="Small" />
                        </ribbon:RibbonButton.ControlSizeDefinition>
                    </ribbon:RibbonButton>
                    <ribbon:RibbonButton Content="MSDN Forums" Label="MSDN Forums"  Height="20" HorizontalAlignment="Left" Margin="0,0,0,0" Name="btnForums" VerticalAlignment="Top" Width="110">
                        <ribbon:RibbonButton.ControlSizeDefinition>
                            <ribbon:RibbonControlSizeDefinition ImageSize="Small" />
                        </ribbon:RibbonButton.ControlSizeDefinition>
                    </ribbon:RibbonButton>
                    <ribbon:RibbonButton Content="About" Label="About" Height="20" HorizontalAlignment="Left" Margin="0,0,0,0" Name="btnAbout" VerticalAlignment="Top" Width="85">
                        <ribbon:RibbonButton.ControlSizeDefinition>
                            <ribbon:RibbonControlSizeDefinition ImageSize="Small" />
                        </ribbon:RibbonButton.ControlSizeDefinition>
                    </ribbon:RibbonButton>
                </ribbon:RibbonGroup>
            <ribbon:RibbonQuickAccessToolBar Margin="0" Width="100" d:LayoutOverrides="Height"/>
            </ribbon:RibbonTab>
			
		</ribbon:Ribbon>
	-->
        <Fluent:Ribbon>
            <!--Backstage-->
            <Fluent:Ribbon.Menu>
                <Fluent:Backstage>
                    <Fluent:BackstageTabControl>
                        <Fluent:BackstageTabItem Header="New"/>
                        <Fluent:BackstageTabItem Header="Open">

                                <!-- Right-side content here -->
                                <StackPanel HorizontalAlignment="Left" Margin="20,0">
                                    <Label FontSize="14" Foreground="DimGray" FontWeight="Bold">Select a Document</Label>
                                </StackPanel>
                            
                        </Fluent:BackstageTabItem>
                        <Fluent:BackstageTabItem Header="Save As"/>
                        <Fluent:Button Name="btnSaveAs" Header="Save As"></Fluent:Button>
                        <Fluent:Button Name="btnExit" Header="Exit"></Fluent:Button>
                    </Fluent:BackstageTabControl>
                </Fluent:Backstage>
            </Fluent:Ribbon.Menu>
            <!--Tabs-->
            <Fluent:RibbonTabItem Header="Home">
                <Fluent:RibbonGroupBox Header="Query">
                    <Fluent:DropDownButton Name="btnRun" Header="Run" >
                        <Fluent:Gallery GroupBy="Group">
                        <Fluent:Button Name="btnRunGrid"  Header="To Grid"></Fluent:Button>
                        <Fluent:Button Name="btnRunQueryTable" Header="To Query Table" ></Fluent:Button>
                        </Fluent:Gallery>
                    </Fluent:DropDownButton>
                </Fluent:RibbonGroupBox>

                <Fluent:RibbonGroupBox Header="Connect">
                    <Fluent:Button Name="btnConnect" Header="Connect"
Icon="Images\Green.png"
LargeIcon="Images\GreenLarge.png" Click="btnConnectClick" />
                    <TextBlock Text="Database:"/>
                    
                    <Fluent:ComboBox Name="cboDatabase" Text="&lt;Select Database&gt;" MinWidth="160" MaxWidth="220" IsEditable="False" SelectionChanged="cboDatabaseSelectionChange"></Fluent:ComboBox>
                </Fluent:RibbonGroupBox>
                <Fluent:RibbonGroupBox Header="Output">
                    <Fluent:ComboBox Name="cboOutputTo" Text="&lt;Output Sheet&gt;" MinWidth="120" MaxWidth="200" IsEditable="False"></Fluent:ComboBox>
                </Fluent:RibbonGroupBox>


            </Fluent:RibbonTabItem>
        </Fluent:Ribbon>
        <Grid Margin="8,4,8,29" Grid.Row="1">
			<Grid.RowDefinitions>
				<RowDefinition Height="0.445*"/>
         		
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="0.35*"/>
				<ColumnDefinition Width="0.65*"/>
			</Grid.ColumnDefinitions>
			<GridSplitter Margin="0,8,0,-8" Width="5" Grid.Column="1" HorizontalAlignment="Left"/>
			<TabControl Margin="0,27,0,8">
				<TabItem Header="Metadata">
					<Grid Background="#FFE5E5E5">
                        <TreeView Name="tvwMetadata">
                            <TreeView.ItemContainerStyle>
                                <!-- 
    This Style binds a TreeViewItem to a PersonViewModel. 
    -->
                                <Style TargetType="{x:Type TreeViewItem}">
                                    <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                                    <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                                    <Setter Property="FontWeight" Value="Normal" />
                                    <Style.Triggers>
                                        <Trigger Property="IsSelected" Value="True">
                                            <Setter Property="FontWeight" Value="Bold" />
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </TreeView.ItemContainerStyle>

                            <TreeView.Resources>
                                
                                <HierarchicalDataTemplate 
                                    DataType="{x:Type ViewModel:TabularModelViewModel}" 
                                    ItemsSource="{Binding Children}"
                                    >
                                    <StackPanel Orientation="Horizontal">
                                        <Image Width="16" Height="16" Margin="3,0" Source="Resources\Folder.ico" />
                                        <TextBlock Text="{Binding ModelName}" />
                                    </StackPanel>
                                </HierarchicalDataTemplate>

                                <HierarchicalDataTemplate DataType="{x:Type ViewModel:TableViewModel}"  ItemsSource="{Binding Children}"   >
                                    <StackPanel Orientation="Horizontal">
                                        <Image Width="16" Height="16" Margin="3,0" Source="Resources\Table.png" />
                                        <TextBlock Text="{Binding TableName}" />
                                    </StackPanel>
                                </HierarchicalDataTemplate>

                                <DataTemplate DataType="{x:Type ViewModel:ColumnViewModel}">
                                    <StackPanel Orientation="Horizontal">
                                        <Image Width="16" Height="16"   Margin="3,0" Source="Resources\Column.png" />
                                        <TextBlock Text="{Binding ColumnName}" />
                                    </StackPanel>
                                </DataTemplate>

                            </TreeView.Resources>
                        </TreeView>
                    </Grid>
				</TabItem>
				<TabItem Header="Functions" Margin="-2,-2,2,-1">
					<Grid Background="#FFE5E5E5"/>
				</TabItem>
				<TabItem Header="DMV" Margin="-2,-2,2,1"/>
			</TabControl>
			
            
    		
               
            
			<ComboBox Margin="0,1.04,0,0" VerticalAlignment="Top" Name="cboModel" />
            <my:DaxEditorUserControl Grid.Column="1" Margin="4,1,0,253" x:Name="daxEditorUserControl1" />

            <GridSplitter Grid.Column="1" Margin="0,0,0,245" d:LayoutOverrides="GridBox" Height="8" VerticalAlignment="Bottom" Width="673" ResizeDirection="Rows" />


            <TabControl Margin="4,0,0,8" Name="tabControl1" Grid.Column="1" Height="236" VerticalAlignment="Bottom">
                <TabItem Header="Messages" Name="tabMessages">
                    <Grid>
                        <local:RichTextBoxWatermarked Height="190" Margin="8,0,1,6" VerticalAlignment="Bottom"/>
                    </Grid>
                </TabItem>
                <TabItem Header="Results" Name="tabResults">
                    <Grid>
                        <DataGrid AutoGenerateColumns="False" Margin="5,5,0,6" Name="grdResults" />
                    </Grid>
                </TabItem>
            </TabControl>
        </Grid>
		<StatusBar Height="29" Margin="8,0,0,0" Grid.Row="1" VerticalAlignment="Bottom">
			<StatusBarItem Width="582"/>
			<StatusBarItem Content="StatusBarItem"/>
			<ResizeGrip Width="15" HorizontalAlignment="Right" RenderTransformOrigin="12.765,0.471"/>
		</StatusBar>
    </Grid>
</Fluent:RibbonWindow>
